// Camera3DataThread
#include "mainwindow.h"


void Camera3DataThread::run()
{
    // int qos = 10;
    rclcpp::QoS video_qos(2);
    video_qos.keep_last(2);
    video_qos.best_effort();
    video_qos.durability_volatile();
    camera3_node_cpp = rclcpp::Node::make_shared("camera_3_node");
    camera3_sub_ = camera3_node_cpp->create_subscription<sensor_msgs::msg::CompressedImage>(
        "camera_3",1, std::bind(&Camera3DataThread::camera3_back, this, std::placeholders::_1));
    rclcpp::spin(camera3_node_cpp);
}

void Camera3DataThread::camera3_back(const sensor_msgs::msg::CompressedImage::SharedPtr img_msg_3)
{
    // 将ROS压缩图像消息转换为OpenCV图像
    cv_bridge::CvImagePtr cv_ptr_3 = cv_bridge::toCvCopy(img_msg_3, sensor_msgs::image_encodings::BGR8);
    img3 = cv_ptr_3->image;
    emit image_3Emit(img3);
}
